﻿using INTEX.DataBase.Tools;
using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using WPFExcelReport.Helpers; 
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for ProductionOrder.xaml
    /// </summary>
    public partial class ITXPDCXS : PDCBase
    {

        public ITXPDCXS()
        {
            try
            {
                InitializeComponent(); 
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        public string fromdate = "", enddate = "", fromdat = "", enddat = ""; string fromdt = ""; string enddt = "";
        DataTable tableUI;
        public DataSet setUI = new DataSet();
        public DataSet setDat = new DataSet();
        private DataRow dwUI;
        ITXEXRPT ITXEXRPT; 
        /// <summary>
        /// SetProd 当前订单
        /// SetData保存所有订单，但是用于展示今日订单
        /// SetEnv保存所有订单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                if (DesignerProperties.GetIsInDesignMode(this))
                    return;
                base.Window_Loaded(sender, e);
                
                //if (app.User.Trim() == "ITXV")
                //{
                    //ABFSTEP = "XS000138001010";
                    //txtKRS.Text = "XS";
                    //txtLFD.Text = "000138";
                    //SPINLOT = "H140201449";
                    //txtDateS.Text = MainViewModel.date;
                   // fromdt = MainViewModel.date;
                 //enddt = MainViewModel.date;
                //}

                Button btnE = this.FindName("btnEDIT") as Button;
                btnE.IsEnabled = false;
                tableUI = new DataTable("UIData");
                tableUI.Columns.Add("FROMDATE", typeof(string));
                tableUI.Columns.Add("ENDDATE", typeof(string));
                tableUI.Columns.Add("BDE", typeof(string));
                tableUI.Columns.Add("LOT", typeof(string));
                tableUI.Columns.Add("TYPE", typeof(string));
                tableUI.Columns.Add("STAFF", typeof(string));
                dwUI = tableUI.NewRow();
                if (ITXEXRPT == null)
                {
                    ITXEXRPT = new ITXEXRPT();//这里是实例化
                    ITXEXRPT.Root = "C:\\IntexReport";
                    ITXEXRPT.strCompany = app.company;
                    ITXEXRPT.PrintType = "OpenExcel"; 
                }
                
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
                MessageBox.Show(ex.StackTrace, ex.Message);
            }
        }
        public override void btnConfirmLine_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                
                if (!CHECKDATA(null, null))
                    return;               
                   
                dwLastPDC = dwTPDC.Table.NewRow();
                dwLastPDC.ItemArray = dwTPDC.ItemArray;
                string staff  = dwTPDC["PDCSTAFF"].ToString().Trim();
               // if (staff.Length <= 5)
                //{
                //    dwTPDC["PDCSTAFF"] = Helper.Right("00000" + staff, 5);
                //}
               // else
                //{
                    dwTPDC["PDCSTAFF"] = staff;
               // }
           
                base.btnConfirmLine_Click(sender, e);
                if (infalg) { MessageBox.Show("数据插入失败，请检查数据并重试！"); return; }
                //int m = Convert.ToInt16(MainViewModel.AMBDEMA.Trim()) + 1;
                int m = Convert.ToInt16(MainViewModel.AMBDEMA.Trim()) + 1;
                txtPDE.Text = m.ToString();
                MACHINEID = m.ToString(); 
                txtPDE.Focus();
                SendToUIThread(txtPDE, "{ENTER}");
               
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }

        }
        public void calculate(object sender,RoutedEventArgs e)
        {
            try
            {
                if (txtSpindles.IsFocused||txtJP24.IsFocused||txtJP26.IsFocused||txtJP27.IsFocused||txtJP28.IsFocused)
                {
                    string JP02 = txtSpindles.Text.ToString().Trim();
                    if (JP02 == "") JP02 = "0";
                    double DJP02 = System.Convert.ToDouble(JP02);
                    string JP28 = txtJP28.Text.ToString().Trim();
                    if (JP28 == "") JP28 = "0";
                    double DJP28 = System.Convert.ToDouble(JP28);
                    string JP24 = txtJP24.Text.ToString().Trim();
                    if (JP24 == "") JP24 = "0";
                    double DJP24 = System.Convert.ToDouble(JP24);
                    string JP26 = txtJP26.Text.ToString().Trim();
                    if (JP26 == "") JP26 = "0";
                    double DJP26 = System.Convert.ToDouble(JP26);
                    string JP27 = txtJP27.Text.ToString().Trim();
                    if (JP27 == "") JP27 = "0";
                    double DJP27 = System.Convert.ToDouble(JP27);
                    double DJP15 = Helper.RoundX(DJP02 * DJP28 / 420, 10);
                    double DJP16 = Helper.RoundX(DJP24 / 420 + DJP26 / 420 / 3 + DJP27 / 420 / 3 * 2, 100);
                    txtJP15.Text = DJP15.ToString();
                    txtJP16.Text = DJP16.ToString();
                    dwTPDC["JP15"] = DJP15.ToString();
                    dwTPDC["JP16"] = DJP16.ToString();
                }

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private bool CHECKDATA(object sender, RoutedEventArgs e)
        {
            try
            {
                if (dwTPDC == null)
                    return true;
                string pdcstaff = dwTPDC["PDCSTAFF"].ToString().Trim();
                if (dwTPDC["PDCDATE"].ToString().Trim().Length == 0)
                {
                    MessageBox.Show("请输入产量日期");
                    return false;
                }
                if (dwTPDC["PDCDATE"].ToString().Trim().Length < 8)
                {
                    MessageBox.Show("请检查日期格式，日期格式为20150801");
                    return false;
                }
                if (pdcstaff != "000" && pdcstaff!="00000")
                {
                    if (dwTPDC["PDCSTAFF"].ToString().Trim().Length == 0)
                    {
                        MessageBox.Show("请输入挡车工");
                        return false;
                    }
                    if (dwTPDC["PDCSHIFT"].ToString().Trim().Length == 0)
                    {
                        MessageBox.Show("请输入班次");
                        return false;
                    }
                    if (dwTPDC["ABFBZAGANG"].ToString().Trim().Length == 0)
                    {
                        MessageBox.Show("没有找到对应生产单");
                        return false;
                    }
                    if (dwTPDC["JP02"].ToString().Trim().Length == 0 || dwTPDC["JP02"].ToString().Trim() == "0")
                    {
                        MessageBox.Show("请输入实开锭数！");
                        return false;
                    }
                    if (dwTPDC["JP06"].ToString().Trim().Length == 0 || dwTPDC["JP06"].ToString().Trim() == "0")
                    {
                        MessageBox.Show("计算KM产量为0，可能原因是在出工数处没有敲回车！");
                        return false;
                    }
                    if (dwTPDC["JP03"].ToString().Trim().Length == 0 || dwTPDC["JP03"].ToString().Trim() == "0")
                    {
                        MessageBox.Show("出工数为0或为空，请修改！");
                        return false;
                    }
                    if (dwTPDC["AMAUFTRVON"].ToString().Trim().Length == 0 || dwTPDC["AMAUFTRVON"].ToString().Trim() == "0")
                    {
                        MessageBox.Show("入工数为0或为空，请修改！");
                        return false;
                    }
                    if (dwTPDC["AMAUFTRVON"].ToString().Trim() == dwTPDC["JP03"].ToString().Trim())
                    {
                        MessageBox.Show("进工数等于出口数，请检查数据！");
                        return false;
                    }
                }
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
            return true;
        }
        public override void ReTry_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (!CHECKDATA(null, null))
                    return;
                string staff = dwTPDC["PDCSTAFF"].ToString().Trim();
                //if (staff.Length <= 5)
               // {
                   // dwTPDC["PDCSTAFF"] = Helper.Right("00000" + staff, 5);
               // }
               // else
               // {
                    dwTPDC["PDCSTAFF"] = staff;
               // }
                base.ReTry_Click(sender, e);
                if (retry) { MessageBox.Show("修改异常，请检查数据并重试！"); return; }
                ReTry.IsEnabled = false;
                vwTPDC.View.MoveCurrentTo(-1);
                //base.btnResetScreen_Click(sender,e);
                TabItem tabE = this.FindName("tabEdit") as TabItem;
                tabE.Focus();
                tabE.IsEnabled = true;
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public void FindMachine()
        {
            TextBox tb;
            if (Convert.ToDouble(dwTPDC["AMSTKBIS"].ToString()) == 0)
            {
                MessageBox.Show("锭数没有设定");
                tb = this.FindName("txtSpindles") as TextBox;
                tb.Focus();
            }
            #region==ICC_PDC======
            /*
            sql = "SELECT * FROM ICC_PDC WHERE TRIM(ABFSTEP)='" + ABFSTEP.Trim() + "' AND TRIM(MACHINEID)='" + MACHINEID.Trim() + "'";
            TResult = SQLiteDatabase.GetDataTable(sql);*/
            DataRow dwData = SetProd.ICC_PDC.NewRow();
            dwData["ABFSTEP"] = ABFSTEP.Trim();
            dwData["MACHINEID"] = MACHINEID.Trim();
            SResult = INTEXDBC.QueryICC_PDC(dwData, 7);
            double JP02 = 0;
            foreach (DataRow row in SResult.Tables[0].Rows)
            {
                JP02 = Convert.ToDouble(row["JP02"].ToString());
                if (JP02 == 0) continue;
                dwTPDC["JP02"] = row["JP02"].ToString().Trim();
                break;
            }

            #endregion
            //spindles 432
            if (JP02 > 0)
            {
                tb = this.FindName("txtSPINHS") as TextBox;
                tb.Focus();
            }
            else
            {
                tb = this.FindName("txtSpindles") as TextBox;
                tb.Focus();
            }
            if (IsStartFromMachine)
            {
                //txtSPINLOT.Focus(); 
            }
            if (IsStartFromSpinLot)
                return;
            dwData = SetProd.ICC_PDC.NewRow();
            dwData["MACHINEID"] = MACHINEID;
            SResult = INTEXDBC.QueryICC_PDC(dwData, 8);
            /*sql = "SELECT  * FROM ICC_PDC  WHERE MACHINEID='" + MACHINEID + "' ORDER BY cast(SUBSTR(ABAID,INSTR(ABAID,'.')+1) as int) DESC";
            TResult = SQLiteDatabase.GetDataTable(sql);*/
            foreach (DataRow row in SResult.Tables[0].Rows)
            {
                dwTPDC["ABFSTEP"] = row["ABFSTEP"];
                dwTPDC["JP10"] = row["JP10"];
                dwTPDC["ABFAUFKRS"] = row["ABFAUFKRS"];
                dwTPDC["ABFAUFLFD"] = row["ABFAUFLFD"];
                dwTPDC["ABFAUFPOS"] = row["ABFAUFPOS"];
                break;
                //txtSPINLOT.Focus();
            }
        }
        public override void txtMACHINE_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key != System.Windows.Input.Key.Enter
                    &&e.Key != System.Windows.Input.Key.Enter
                    )
                    return; 
               base.txtMACHINE_KeyUp(sender, e);                

                TextBox tb = sender as TextBox;
                if (tb.Text.Trim().Length == 0)
                    return;
                FindMachine();
                SendToUIThread(txtSPINLOT, "{ENTER}");
                txtSPINHS.Focus();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public override void txtMTERS_KeyUp(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.Key != System.Windows.Input.Key.Enter)
                    return;
                if (dwTPDC == null)
                    return;
                dwTPDC["JP06"] = ((TextBox)sender).Text;
                double JP01 = Convert.ToDouble(dwTPDC["JP01"].ToString());//yarn count 21
                double JP02 = Convert.ToDouble(dwTPDC["JP02"].ToString());//spindles 432
                double JP06 = Convert.ToDouble(dwTPDC["JP06"].ToString()); //METER
                double JP13 = Convert.ToDouble(dwTPDC["AMSTKBIS"].ToString()); //MAX
                if (JP13 == 0)
                    JP13 = 420;
                double rounds = JP06;
                double N3 = Convert.ToDouble(dwTPDC["JP12"].ToString());
                double KG = Helper.RoundX(JP06 * JP13 * 100 * N3 / 1000000 * 10, 100);
                //double KG = 0.4536 * (rounds * JP02 / 0.9144) / (JP01 * 840);
                dwTPDC["QTY"] = KG;
                btnOK.Focus();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public override void txtSPINHS_KeyUp(object sender, KeyEventArgs e)
        {
            if (e.Key != System.Windows.Input.Key.Enter)
                return;
            if (dwTPDC == null)
                return;
            try
            {
                string text = ((TextBox)sender).Text;
                double JP03 = Convert.ToDouble(text);
                dwTPDC["JP03"] = JP03;
                double JP01 = Convert.ToDouble(dwTPDC["JP01"].ToString());//yarn count 21
                double JP02 = Convert.ToDouble(dwTPDC["JP02"].ToString());//spindles 432
                if (dwTPDC["JP03"].ToString().Trim() == "0")
                {
                    dwTPDC["JP03"] = "0";
                }
                JP03 = Convert.ToDouble(dwTPDC["JP03"].ToString());//meter  12345
                if (dwTPDC["AMAUFTRVON"].ToString().Trim() == "")
                {
                    dwTPDC["AMAUFTRVON"] = "0";
                }

                double JP04 = Convert.ToDouble(dwTPDC["AMAUFTRVON"].ToString());// LAST
                double JP05 = Convert.ToDouble(dwTPDC["AMAUFTRBIS"].ToString()); //MAX 
                double JP13 = Convert.ToDouble(dwTPDC["AMSTKBIS"].ToString()); //MAX CONES
                if (JP13 == 0)
                    JP13 = 420;
                double ABSMETER = JP03 - JP04;
                if (ABSMETER < 0)//有过清零
                {
                    ABSMETER = JP05 - JP04 + JP03;
                }
                double JP06 = ABSMETER * JP02 / JP13 / 100;
                dwTPDC["JP06"] = Helper.RoundX(JP06, 100);
                double N3 = Convert.ToDouble(dwTPDC["JP12"].ToString());
                double KG = Helper.RoundX(Helper.RoundX(JP06,100) * JP13 * 100 * N3 * 0.98 / 1000000 * 10 * 0.95, 100);//0.4536 * (rounds * JP02 / 0.9144) / (JP01 * 840);
                //double KG = Helper.RoundX(JP06 * JP13 * 100 * N3 / 1000000 * 10, 100);//0.4536 * (rounds * JP02 / 0.9144) / (JP01 * 840);
                dwTPDC["QTY"] = KG;
                DataRow dwData = SetProd.AMSTAMM.NewRow();
                dwData["AMMANDANT"] = app.Mandant;
                dwData["AMNRKRS"] = dwTPDC["ABFIMNRKRS"];
                dwData["AMLFDNR"] = dwTPDC["ABFIMLFDNR"];
                dwData["AMPOS"] = dwTPDC["ABFIMPOS"];
                dwData["AMAUFTRVON"] = JP03;
                INTEXDBC.UpdateAMSTAMM(dwData, 2);

                btnOK.Focus();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
                MessageBox.Show(ex.StackTrace, ex.Message);
            }
        }
        public override void txtSPINLOT_KeyUp(object sender, KeyEventArgs e)
       {
            try
            {
                
                if (e.Key != System.Windows.Input.Key.Enter)
                    return;
                base.txtSPINLOT_KeyUp(sender, e);
                /*if (IsStartFromMachine)
                    return;
                txtPDE.Focus();
                return;*/
                if (falg) { MessageBox.Show("根据批号查找订单时出错，请核对批号或通知计划人员相应批号检查！"); return; }
                if (MACHINEID == "        ")
                {
                    txtPDE.Focus();
                    return;
                }
                #region==ICC_PDC======
                DataRow dwData = SetProd.ICC_PDC.NewRow();
                dwData["ABFSTEP"] = ABFSTEP.Trim();
                dwData["MACHINEID"] = MACHINEID.Trim();
                /*sql = "SELECT * FROM ICC_PDC WHERE TRIM(ABFSTEP)='" + ABFSTEP.Trim() + "' AND MACHINEID='"+MACHINEID+"' ORDER BY ABAID DESC";
                TResult = SQLiteDatabase.GetDataTable(sql);*/
                SResult = INTEXDBC.QueryICC_PDC(dwData, 7);
                foreach (DataRow row in SResult.Tables[0].Rows)
                {
                    string mid = Helper.Left(row["MACHINEID"].ToString().PadRight(8), 8);
                    if (mid.Trim() == "")
                        continue;
                    //MACHINEID = mid;
                    //dwTPDC["MACHINEID"] = mid;
                    dwTPDC["JP02"] = row["JP02"];
                    //LookForMachine(dwTPDC);
                    break;
                }
                #endregion
                txtSPINHS.Focus();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void FROM_DT_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                fromdt = "";
                fromdt = INTEXDBC.GetDate(sender);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }

        }
        private void END_DT_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                enddt = "";
                enddt = INTEXDBC.GetDate(sender);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }

        }
        public virtual void Load_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                //string dates = txtDateS.Text.ToString().Trim();
                string qm = txtQM.Text.ToString().Trim();
                //string datee = txtDateE.Text.ToString().Trim();
                //string _date = "", _stime = "", _time = "";
                //Helper.GetSTime(ref _date, ref _time, ref _stime);
                if (fromdt == "")
                    //datee = _date;
                    fromdt= "20000000";
                if (enddt == "")
                    //dates = Helper.GetDateAddDays(_date, -6);
                    enddt = "99999999";
                if (qm == "") qm = "AA";
                /*
                sql = "SELECT * FROM ICC_PDC WHERE TRIM(ABFAGANG)='" + ABFAGANG.Trim() + "' AND TRIM(AMBDEMA)='" + qm + "' AND NEWDATE>='" + dates + "' AND NEWDATE<='" + datee + "'";
                TBResult = SQLiteDatabase.GetDataTable(sql);*/
                DataRow dwData = SetProd.ICC_PDC.NewRow();
                //dwData["ABFAGANG"] = ABFAGANG.Trim();
                dwData["AMBDEMA"] = qm.Trim();
                dwData["NEWDATE"] = fromdt;
                dwData["CHGDATE"] = enddt;
                SResult = INTEXDBC.QueryICC_PDC(dwData, 13);
                SetData.Clear();
                SetData.Merge(SResult);
                
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        private void txtSPINLOT_GotFocus(object sender, RoutedEventArgs e)
        {
            //Cursor myWPFCursor = System.Windows.Input.Cursors.Hand;
            TextBox tb = sender as TextBox;

        }
        public override void Save()
        { 
            base.Save();
        }
        private void FROM_DATE_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                fromdate = "";
                fromdate = INTEXDBC.GetDate(sender);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }

        }
        private void END_DATE_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                enddate = "";
                enddate = INTEXDBC.GetDate(sender);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }

        }

        private void btnQuery_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                DataSet setResult = new DataSet();
                setUI.Clear();
                setUI.AcceptChanges();
                string BDE = txtBDE.Text.ToString().Trim();
                string STAFF = txtSTAFF.Text.ToString().Trim();
                string LOT = txtLOT.Text.ToString().Trim();

                if (BDE == "")
                {
                    BDE = "AAA";
                }
                if (LOT == "")
                {
                    LOT = "AAA";
                }
                if (fromdate == "")
                {
                    fromdate = "20000000";
                }
                if (enddate == "")
                {
                    enddate = "99999999";
                }
                dwUI["FROMDATE"] = fromdate;
                dwUI["ENDDATE"] = enddate;
                dwUI["LOT"] = LOT;
                dwUI["BDE"] = BDE;
                dwUI["STAFF"] = STAFF;
                dwUI["TYPE"] = "XS";
                setResult = INTEXDBC.QueryICC_PDC(dwUI,5);
                setUI.Merge(setResult);
                dlgOrder.DataContext = setUI.Tables["ICC_PDC"];
                

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
                MessageBox.Show(ex.StackTrace, ex.Message);
            }
        }

        private void btnEXCEL_Click(object sender, RoutedEventArgs e)
        {

            try
            {
               //这里发现为null，那就是没有实例化，或没有实例化成功
                ITXEXRPT.dsSource = setUI;
                //ITXEXRPT.dsSource.Merge(setUI);
                ITXEXRPT.DocType = app.company + "PDC";
                ITXEXRPT.strExcelFile = app.company + @"\YGRREPORT.xls";
                string filename = ITXEXRPT.WriteExcelReport();
            } 
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void FROM_DAT_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                fromdat = "";
                fromdat = INTEXDBC.GetDate(sender);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void END_DAT_SelectedDateChanged(object sender, SelectionChangedEventArgs e)
        {
            try
            {
                enddat = "";
                enddat = INTEXDBC.GetDate(sender);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        private void btnSum_Click(object sender, RoutedEventArgs e)
        {
            DataSet setResult = new DataSet();
            setDat.Clear();
            setDat.AcceptChanges();

            if (fromdat == "")
            {
                fromdat = "20000000";
            }
            if (enddat == "")
            {
                enddat = "99999999";
            }
            dwUI["FROMDATE"] = fromdat;
            dwUI["ENDDATE"] = enddat;
            dwUI["TYPE"] = "XS";
            setResult = INTEXDBC.QueryICC_PDC(dwUI, 6);
            setDat.Merge(setResult);
            dlgSummary.DataContext = setDat.Tables["ICC_PDC"];
                
        }

        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                ITXEXRPT.dsSource = setDat;
                ITXEXRPT.dsSource.Merge(setDat);
                ITXEXRPT.DocType = app.company + "PDCTOT";
                ITXEXRPT.strExcelFile = app.company + @"\YGRREPORT.xls";
                string filename = ITXEXRPT.WriteExcelReport();
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
                MessageBox.Show(ex.StackTrace, ex.Message);
            }
        }

    }

}
